package com.wanxi.iterator;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class IteratorStudent {
    public static void main(String[] args) {
        List<Student> list=new ArrayList<>();
        list.add(new Student("张三",11));
        list.add(new Student("李四",12));
        list.add(new Student("王五",13));
        Iterator<Student> iterator = list.iterator();
        while (iterator.hasNext()){
            Student next = iterator.next();
            if(next.getName().equals("李四")){
//                iterator.remove();
                next.setName("aaa");
            }
        }
        System.out.println(list);
    }
}
